package com.heima.comment.controller;

import com.heima.comment.dto.CommentDto;
import com.heima.comment.dto.CommentLikeDto;
import com.heima.comment.dto.CommentSaveDto;
import com.heima.comment.serivce.IApCommentService;
import com.heima.common.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 评论控制器
 *
 * @Name : ApCommentController
 * @Author : WuQiang
 * @Date : 2022-10-16 20:34
 * @Description : 评论控制器
 */
@RestController
@RequestMapping("/api/v1/comment")
public class ApCommentController {

    @Autowired
    private IApCommentService apCommentService;

    /**
     * 保存评论
     *
     * @param dto dto
     * @return {@code ResponseResult}
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody CommentSaveDto dto) {
        return apCommentService.save(dto);
    }

    /**
     * 评论列表展示
     *
     * @param dto dto
     * @return {@code ResponseResult}
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody CommentDto dto) {
        return apCommentService.load(dto);
    }

    /**
     * 评论点赞
     *
     * @param dto dto
     * @return {@link ResponseResult}
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto) {
        return apCommentService.like(dto);
    }
}
